#!/bin/bash

echo "============================================="
echo "Starting backend and frontend applications..."
echo "============================================="

# 检查Node.js是否安装
if ! command -v node &> /dev/null; then
    echo "错误: 未找到Node.js。请先安装Node.js后再试。"
    exit 1
fi

# 使用mcp工具启动服务
echo "Starting backend application (port 8081)..."
node mcp.js start

# 检查启动是否成功
if [ $? -eq 0 ]; then
    echo "============================================="
    echo "Applications started successfully!"
    echo "Backend service running at: http://localhost:8081/"
    echo "Frontend service usually runs at: http://localhost:2180/ or http://localhost:2181/"
    echo "Please access the frontend address in your browser"
    echo "============================================="
else
    echo "============================================="
    echo "Failed to start applications. Please check logs."
    echo "============================================="
    exit 1
fi